function relaxxx
global lam

lam=100;
ep=1/lam
t1=1.5-log(2)

%  initial values
%tmax=t1-0.01;
tmax=t1-0.00001
y10=2; y20=-2/3;
y0=[y10 y20];
options = odeset('RelTol', 1e-10,'AbsTol',1e-10);
[t,y] = ode23s(@rhs,[0 tmax],y0,options);
nt=length(t)
y0(1)=y10;
d(1)=0;
for i=2:nt
	y0(i)=solve(@(x)log(x/2)-0.5*x^2+2-t(i),1,y0(i-1));
    d(i)=y(i,1)-y0(i);
end

figure(1)
clf
hold on
plot(t,d,'--r','LineWidth',1.5)
plot([t1 t1],[0 max(d)],'k','LineWidth',0.5)
axis([0.78 0.83 0 max(d)])
xlabel('\tau-axis','FontWeight','bold')
ylabel('d','FontWeight','bold')
grid on
box on
set(gca,'FontSize',12,'FontWeight','bold')
hold off

figure(2)
clf
hold on
plot(t,y0,'--r','LineWidth',1.5)
plot(t,y(:,1),'b','LineWidth',1.5)
axis([0.7 0.81 0.9 1.3])
xlabel('\tau-axis','FontWeight','bold')
ylabel('y-axis','FontWeight','bold')
grid on
box on
set(gca,'FontSize',12,'FontWeight','bold')
hold off

figure(3)
clf
hold on
%plot(t,y0,'--r','LineWidth',1.5)
plot(t,y(:,2),'b','LineWidth',1.5)
xlabel('\tau-axis','FontWeight','bold')
ylabel('u-axis','FontWeight','bold')
grid on
box on
set(gca,'FontSize',12,'FontWeight','bold')
hold off

%  define f(t,y)
function dy=rhs(t,y)
global lam
dy=zeros(2,1);
dy(1) = lam^2*(y(1)*(1-y(1)^2/3)-y(2));
dy(2) = y(1);








